import 'package:flutter/material.dart';
import 'package:manual/theme/loading_ovaerlay_theme.dart';
import 'package:manual/theme/screen_modal_theme.dart';

class AppThemes {
  // 亮色主题
  static final ThemeData lightTheme = ThemeData(
    brightness: Brightness.light,
    primaryColor: Colors.blue,
    scaffoldBackgroundColor: Colors.white,
    appBarTheme: const AppBarTheme(
      backgroundColor: Colors.blue,
      foregroundColor: Colors.white,
    ),
    textTheme: const TextTheme(
      bodyLarge: TextStyle(color: Colors.black),
      bodyMedium: TextStyle(color: Colors.black87),
    ),
    elevatedButtonTheme: ElevatedButtonThemeData(
      style: ElevatedButton.styleFrom(
        foregroundColor: Colors.white,
        backgroundColor: Colors.blue,
      ),
    ),
    textButtonTheme: TextButtonThemeData(
      style: ButtonStyle(
        foregroundColor: WidgetStateProperty.resolveWith((states) {
          // 设置按钮文字颜色
          if (states.contains(WidgetState.disabled)) {
            return Colors.grey; // 禁用状态颜色
          }
          return const Color.fromARGB(255, 16, 44, 66); // 默认文字颜色
        }),
        overlayColor: WidgetStateProperty.resolveWith((states) {
          // 设置按钮点击时的背景效果
          if (states.contains(WidgetState.pressed)) {
            return const Color.fromARGB(255, 16, 44, 66).withOpacity(0.1);
          }
          return null;
        }),
      ),
    ),
    // 扩展主题  上述的都是内置主题
    extensions: [
      ScreenModalTheme(
        backgroundColor: Colors.white,
        indicatorColor: Colors.grey[300]!,
        closeButtonColor: Colors.red,
        completeButtonColor: Colors.green,
        closeButtonTextStyle: const TextStyle(color: Colors.red, fontSize: 14.0),
        completeButtonTextStyle: const TextStyle(color: Colors.green, fontSize: 14.0),
      ),
      LoadingOverlayTheme(
        backgroundColor: const Color.fromARGB(222, 0, 0, 0), // 浅色背景
        loadingColor: Colors.white
      ),
    ]
  );

  // 暗色主题
  static final ThemeData darkTheme = ThemeData(
    brightness: Brightness.dark,
    primaryColor: Colors.grey[900],
    scaffoldBackgroundColor: Colors.black,
    appBarTheme: AppBarTheme(
      backgroundColor: Colors.grey[900],
      foregroundColor: Colors.white,
    ),
    textTheme: const TextTheme(
      bodyLarge: TextStyle(color: Colors.white),
      bodyMedium: TextStyle(color: Colors.white70),
    ),
    elevatedButtonTheme: ElevatedButtonThemeData(
      style: ElevatedButton.styleFrom(
        foregroundColor: Colors.grey[800],
        backgroundColor: Colors.white,
      ),
    ),
    textButtonTheme: TextButtonThemeData(
      style: ButtonStyle(
        foregroundColor: WidgetStateProperty.resolveWith((states) {
          // 设置按钮文字颜色
          if (states.contains(WidgetState.disabled)) {
            return Colors.grey; // 禁用状态颜色
          }
          return const Color.fromARGB(255, 246, 252, 255); // 默认文字颜色
        }),
        overlayColor: WidgetStateProperty.resolveWith((states) {
          // 设置按钮点击时的背景效果
          if (states.contains(WidgetState.pressed)) {
            return const Color.fromARGB(255, 246, 252, 255).withOpacity(0.1);
          }
          return null;
        }),
      ),
    ),
    extensions: [
      ScreenModalTheme(
        backgroundColor: Colors.black,
        indicatorColor: Colors.grey[700]!,
        closeButtonColor: Colors.red[300]!,
        completeButtonColor: Colors.green[300]!,
        closeButtonTextStyle: TextStyle(color: Colors.red[300], fontSize: 14.0),
        completeButtonTextStyle:TextStyle(color: Colors.green[300], fontSize: 14.0),
      ),
      LoadingOverlayTheme(
        backgroundColor: const Color.fromARGB(222, 255, 255, 255), // 浅色背景
        loadingColor: Colors.black
      ),
    ],
  );
}
